package edu.spec.sms.dao.impl;

import edu.spec.sms.dao.iface.IExamDao;
import edu.spec.sms.model.mental.Exam;
import edu.spec.sms.model.mental.Mental;
import org.madgecko.basic.dao.BaseDao;
import org.madgecko.basic.model.Pager;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ExamDao extends BaseDao<Exam> implements IExamDao {
    @Override
    public Pager<Exam> find() {
        String hql = " from Exam e order by e.createDate desc";
        return this.find(hql);
    }

    @Override
    public void deletelClazz(Integer examId, Integer clazzId) {
        String hql = "delete from ExamClazz ec where ec.exam.id=" + examId + " and ec.clazz.id=" + clazzId;
        this.updateByHql(hql);
    }

    @Override
    public List<Integer> listClazzIdsByExam(Integer examId) {
        String hql = "select ec.clazz.id from ExamClazz ec where ec.exam.id=" + examId;
        return this.listIdByHql(hql);
    }

    @Override
    public List<Mental> listMentalByStudent(Integer studentId) {
        String hql = "select sm.mental from StudentMental sm where sm.student.id" + studentId;
        return null;
    }
}
